home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-10-06 | 4.4 KB | 169 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // SWCommonHeaders.h
- //
- // Portions are copyright: c 1991-94 Tony Myles, All rights reserved worldwide.
- //
- // Description: common macros, constants, and stuff, used throughout SpriteWorld
- ///--------------------------------------------------------------------------------------
-
- #ifndef __SWCOMMON__
- #define __SWCOMMON__
-
- ///--------------------------------------------------------------------------------------
- // VBL-related stuff
- ///--------------------------------------------------------------------------------------
-
- #ifndef __RETRACE__
- #include <Retrace.h>
- #endif
-
- typedef struct VBLTaskRec VBLTaskRec;
- typedef VBLTaskRec *VBLTaskRecPtr, **VBLTaskRecHdl;
-
- struct VBLTaskRec
- {
- VBLTask myVBLTask;
- volatile Boolean hasVBLFired;
- };
-
-
- ///--------------------------------------------------------------------------------------
- // sprite world definitions
- ///--------------------------------------------------------------------------------------
-
- typedef struct SpriteWorldRec SpriteWorldRec, *SpriteWorldPtr, **SpriteWorldHdl;
-
- typedef struct SpriteLayerRec SpriteLayerRec, *SpriteLayerPtr, **SpriteLayerHdl;
-
- typedef struct SpriteRec SpriteRec, *SpritePtr, **SpriteHdl;
-
- typedef struct FrameRec FrameRec, *FramePtr, **FrameHdl;
-
-
- ///--------------------------------------------------------------------------------------
- // SW_ASSERT
- ///--------------------------------------------------------------------------------------
-
- #ifndef SW_ASSERT_ON
- #define SW_ASSERT_ON 1 // Change this to 0 to turn assertions off. use 1/0, not true/false.
- #endif
-
- #define kAssertAlertID 128 // The resource ID of the Alert dialog box used for assertions.
-
- #if (SW_ASSERT_ON == 1)
- #define SW_ASSERT( condition ) \
- if ( !(condition) ) \
- SWAssertFail( __FILE__, __LINE__ ); // Defined in SpriteWorldUtils.c
- #else
- #define SW_ASSERT(f) NULL
- #endif
-
-
- ///--------------------------------------------------------------------------------------
- // sprite world macros
- ///--------------------------------------------------------------------------------------
-
- #if defined(powerc) || defined(__powerc)
- #define SW_68K 0
- #define SW_PPC 1
- #else
- #define SW_68K 1
- #define SW_PPC 0
- #endif
-
- // set to 'pascal' so the library will be callable from pascal too
- #define SW_FUNC pascal
-
-
- #define SW_ABS(x) ((x) < (0) ? -(x) : (x))
-
- #define SW_MIN(a, b) ((a) < (b) ? (a) : (b))
- #define SW_MAX(a, b) ((a) > (b) ? (a) : (b))
-
- #define SW_RECT_WIDTH(theRect) (theRect.right - theRect.left)
- #define SW_RECT_HEIGHT(theRect) (theRect.bottom - theRect.top)
-
- #define SW_SET_RECT(theRect, myleft, mytop, myright, mybottom) \
- { \
- theRect.left = myleft; \
- theRect.top = mytop; \
- theRect.right = myright; \
- theRect.bottom = mybottom; \
- }
-
-
- #define SW_RECT_IS_IN_RECT(rectA, rectB) \
- ( (rectA.top < rectB.bottom) && \
- (rectA.bottom > rectB.top) && \
- (rectA.left < rectB.right) && \
- (rectA.right > rectB.left) )
-
- // Clips rectA with rectB
- #define SW_CLIP_RECT(rectA, rectB) \
- if (rectA.top < rectB.top) \
- rectA.top = rectB.top; \
- if (rectA.bottom > rectB.bottom) \
- rectA.bottom = rectB.bottom; \
- if (rectA.left < rectB.left) \
- rectA.left = rectB.left; \
- if (rectA.right > rectB.right) \
- rectA.right = rectB.right;
-
- // Clips dstRect and srcRect with clipRect.
- #define SW_CLIP_DST_AND_SRC_RECT(dstRect, srcRect, clipRect) \
- if (dstRect.top < clipRect.top) \
- { \
- srcRect.top += clipRect.top - dstRect.top; \
- dstRect.top = clipRect.top; \
- } \
- if (dstRect.bottom > clipRect.bottom) \
- { \
- srcRect.bottom += clipRect.bottom - dstRect.bottom; \
- dstRect.bottom = clipRect.bottom; \
- } \
- if (dstRect.left < clipRect.left) \
- { \
- srcRect.left += clipRect.left - dstRect.left; \
- dstRect.left = clipRect.left; \
- } \
- if (dstRect.right > clipRect.right) \
- { \
- srcRect.right += clipRect.right - dstRect.right; \
- dstRect.right = clipRect.right; \
- }
-
- /*
- * Generally MacHeaders provides these 2 macros for us in CodeWarrior.
- * They're here if you don't use MacHeaders for some reason.
- */
-
- #ifndef topLeft
- #define topLeft(r) (((Point *) &(r))[0])
- #endif
-
- #ifndef botRight
- #define botRight(r) (((Point *) &(r))[1])
- #endif
-
- #define kBitsPerByte 8
-
- #if __MWERKS__
-
- #define SW_ASM_FUNC asm
- #define SW_ASM_BEGIN machine 68020
- #define SW_ASM_END rts
-
- #elif THINK_C
-
- #define SW_ASM_FUNC
- #define SW_ASM_BEGIN asm 68020{
- #define SW_ASM_END }
-
- #endif
-
- #endif /*__SWCOMMON__*/
-
-
-
-
-